package com.sleepfish.web.core.config;

import com.github.alenfive.rocketapi.extend.IResultWrapper;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class DefaultResultWrapper  implements IResultWrapper {

    @Override
    public Object wrapper(Object data, HttpServletRequest request, HttpServletResponse response) {
        return new ResultWrapper(200,request.getRequestURI(),"操作成功",data);
    }

    @Override
    public Object throwable(Throwable throwable, HttpServletRequest request, HttpServletResponse response) {
        return new ResultWrapper(500,request.getRequestURI(),throwable.getMessage(),null);
    }
}